
#ifndef	__KC_SAKCAB_AUBIN_HPP_2010__
#define	__KC_SAKCAB_AUBIN_HPP_2010__


#include <boost/date_time/posix_time/posix_time.hpp>
using namespace boost::posix_time;

namespace   sakcab   {


class   AubinConfig
{
public  :
    AubinConfig( const char* ini_filename, const char* ini_section );

public  :
    std::string data_home;
    int32_t     slim;
	int32_t		skey_size;
	u_int32_t	file_rotate_size;

	std::string	file_key_encode;
	bool		file_key_encode_base64_b;

	std::string	file_value_encode;
	bool		file_value_encode_base64_b;

	bool		file_op_log;

	std::string	snap_home;
	int32_t		snap_copies;
	int32_t		snap_interval;	// in seconds
};  //// class AubinConfig


class   Aubin
{

public  :
    virtual	~Aubin() {}

public  :
    virtual	int insert( const std::string& kpin,
					    const std::string& key,
					    const std::string& data ) = 0;

    virtual	int insertAppend( const std::string& kpin,
							  const std::string& key,
							  const std::string& data ) = 0;

    virtual	int insertIgnore( const std::string& kpin,
							  const std::string& key,
							  const std::string& data ) = 0;

    virtual	int find( const std::string& kpin,
					  const std::string& key,
							std::string& data ) = 0;

    virtual	int find( const std::string& kpin,
					  const std::string&  key,
							std::vector< std::string >& data,
							u_int32_t     limit = 0 ) = 0;

    virtual	int erase( const std::string& kpin,
					   const std::string& key ) = 0;

	virtual	int	slim( void ) = 0;

public  :

    virtual	int     insertAppend( const std::vector< std::string >& kpin,
								  const std::vector< std::string >& key,    
								  const std::vector< std::string >& data ) = 0;

};  //// class Aubin


///////////////////////////////////////////////////////////////////////


class	AubinMeter
{

public	:
	AubinMeter( const std::string& id );

public	:
	void	countInsert( long ms );
	void	countFind( long ms );
	void	countErase( long ms );

private	:
	std::string	_id;

	int64_t		sum_ms_get_op;
	int32_t		count_get_op;
	int64_t		sum_ms_put_op;
	int32_t		count_put_op;
	int64_t		sum_ms_erase_op;
	int32_t		count_erase_op;
};

///////////////////////////////////////////////////////////////////////

int		checkSnapshotCopies( const char* snap_home, const char* filename_prefix, int32_t copies );

long	getTimeDuration( ptime time_begin, ptime time_end );


}   //// namespace sakcab


#endif	////	__KC_SAKCAB_AUBIN_HPP_2010__

